﻿<UserControl x:Class="ViewAnalysis"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Padding="{TemplateBinding Padding}">
                            <Grid Background="Transparent" SnapsToDevicePixels="False">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="19"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Ellipse x:Name="circle" HorizontalAlignment="Center" Height="19" Stroke="DarkGray" VerticalAlignment="Center" Width="19"/>
                                <Path x:Name="arrow" Data="M 1,1.5 L 4.5,5 L 8,1.5" HorizontalAlignment="Center" SnapsToDevicePixels="false" Stroke="#666" StrokeThickness="2" VerticalAlignment="Center"/>
                                <ContentPresenter Grid.Column="1" HorizontalAlignment="Stretch"  Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="true">
                                <Setter Property="Data" TargetName="arrow" Value="M 1,4.5  L 4.5,1  L 8,4.5"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Stroke" TargetName="circle" Value="#FF3C7FB1"/>
                                <Setter Property="Stroke" TargetName="arrow" Value="#222"/>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter Property="Stroke" TargetName="circle" Value="#FF526C7B"/>
                                <Setter Property="StrokeThickness" TargetName="circle" Value="1.5"/>
                                <Setter Property="Stroke" TargetName="arrow" Value="#FF003366"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ExpanderStyle" TargetType="{x:Type Expander}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Expander}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="3" SnapsToDevicePixels="true">
                            <DockPanel>
                                <ToggleButton x:Name="HeaderSite" 
                                              ContentTemplate="{TemplateBinding HeaderTemplate}" 
                                              ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                              Content="{TemplateBinding Header}" 
                                              DockPanel.Dock="Top" 
                                              Foreground="{TemplateBinding Foreground}"
                                              FontWeight="{TemplateBinding FontWeight}" 
                                              FontStyle="{TemplateBinding FontStyle}"
                                              FontStretch="{TemplateBinding FontStretch}"
                                              FontSize="{TemplateBinding FontSize}" 
                                              FontFamily="{TemplateBinding FontFamily}"
                                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                              IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                                              Margin="1" 
                                              MinWidth="0"
                                              MinHeight="0"
                                              Padding="{TemplateBinding Padding}"
                                              Style="{StaticResource ExpanderDownHeaderStyle}"
                                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                <ContentPresenter x:Name="ExpandSite" DockPanel.Dock="Bottom" Focusable="false" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </DockPanel>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="true">
                                <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Button Content="Inserer une etape" Padding="5" Margin="5" VerticalAlignment="Center" Background="White" FontWeight="Bold" FontSize="14" Foreground="Green" Name="Button1" />
            <ComboBox Background="White" Grid.Column="1"  VerticalAlignment="Center" Margin="5" Padding="5" Name="StagesCombobox"/>
        </Grid>
        <ListBox Name="ProcessListbox" Grid.Row="1"  HorizontalContentAlignment="Stretch"  >
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate  TargetType="ListBoxItem">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="30" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>

                                    <RadioButton
                                        IsThreeState="False" 
                                        IsChecked="{TemplateBinding IsSelected}" 
                                        VerticalAlignment="Center" 
                                        HorizontalAlignment="Center" 
                                        GroupName="SelectionGroup" />

                                    <Expander HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"  Style="{StaticResource ExpanderStyle}" Background="LightGray"  Grid.Column="1" >
                                        <Expander.Header>
                                            <Grid HorizontalAlignment="Stretch">
                                                <TextBox BorderBrush="{x:Null}" Background="{x:Null}" BorderThickness="0" Text="{Binding Path=StageName, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" >
                                                    <Button Command="{Binding}" CommandParameter="Compute" Padding="1" Margin="1" Background="White" Content="Recalculer" />
                                                    <Button Command="{Binding}" CommandParameter="Edit"  Padding="1" Margin="1" Background="White" Content="Modifier" />
                                                </StackPanel>
                                            </Grid>
                                        </Expander.Header>
                                        <ContentPresenter Content="{Binding View}"   HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  />
                                    </Expander>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
            <!--<ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="30" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <RadioButton
                            IsThreeState="False" 
                            IsChecked="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}, Path=IsSelected}" 
                            VerticalAlignment="Center" HorizontalAlignment="Center" GroupName="SelectionGroup" />

                        <Expander  Style="{StaticResource ExpanderStyle}" Background="LightGray"  Grid.Column="1" HorizontalContentAlignment="Stretch" >
                            <Expander.Header>
                                <Grid HorizontalAlignment="Stretch">
                                    <TextBlock Text="{Binding Type}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                    <Button Command="{Binding}" Padding="1" Margin="1" Background="White" VerticalAlignment="Center" HorizontalAlignment="Right" Content="Recalculer" />
                                </Grid>
                            </Expander.Header>
                            <Grid MinHeight="100" >
                                <ContentPresenter Content="{Binding View}" />
                            </Grid>
                        </Expander>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>-->
        </ListBox>

    </Grid>
</UserControl>
